﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils.Extention;
#region Version Info
/* ========================================================================
* 【本页面功能概述】
*
* 作者：wangjianfeng 创建时间：2012/9/16 14:34:03
* 文件名：Case.cs
*
* 修改者： 时间：
* 修改说明：
* ========================================================================
*/
#endregion
namespace ChinaLeg.Web.News
{
    public partial class Case : System.Web.UI.Page
    {
        protected string title, description, keyWrods, bgImage, adScroll;

        protected int catid;
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!this.IsPostBack)
            {
                if (!Request.QueryString["id"].IsNullOrEmpty())
                {
                    int id = Request.QueryString["id"].ToInt32();

                    ChinaLeg.Model.CaseShow model = ChinaLeg.BLL.CaseShow.Instance.GetModel(id);
                    if (model != null)
                    {
                        catid = model.CatId;

                        hlCat.Text = hlCat2.Text = ChinaLeg.Cache.Category.Instance.GetCatName(catid);
                        hlCat.NavigateUrl = hlCat2.NavigateUrl = Lib.WebLinks.GetCaseCatLinks(catid);



                        int parentcatid = ChinaLeg.Cache.Category.Instance.GetParentId(catid);

                        hlParent.Text = hlParent2.Text = ChinaLeg.Cache.Category.Instance.GetCatName(parentcatid);
                        hlParent.NavigateUrl = hlParent2.NavigateUrl = Lib.WebLinks.GetCatLinks(parentcatid); 
                        litTitle.Text = model.Name;
                        litContent.Text = model.Content;
                        litDescription.Text = model.Description;

                        ChinaLeg.Model.CaseShow next = ChinaLeg.BLL.CaseShow.Instance.GetNextModel(id, catid);
                        if (next != null)
                        {
                            hlNextNews.Text = "下一篇:"+next.Name;
                            hlNextNews.NavigateUrl = Lib.WebLinks.GetCaseLink(next.Id);
                        }
                        else
                        {
                            hlNextNews.Text = "下一篇:没有了";
                        }
                        ChinaLeg.Model.CaseShow prev = ChinaLeg.BLL.CaseShow.Instance.GetPrevModel(id, catid);
                        if (prev != null)
                        {
                            hlPrevNews.Text = "上一篇:"+ prev.Name;
                            hlPrevNews.NavigateUrl = Lib.WebLinks.GetCaseLink(prev.Id);
                        }
                        else
                        {
                            hlPrevNews.Text = "上一篇:没有了";
                        }
                        

                        ChinaLeg.Cache.Category.Instance.GetModel(parentcatid, out title, out  keyWrods, out  description, out  bgImage);
                        Top1.CatId = parentcatid;
                        Top1.BgImage = bgImage;
                        title = model.Name;
                        keyWrods = model.KeyWords;
                        description = model.Description;

                        rptRelation.DataSource = ChinaLeg.BLL.News.Instance.GetList(" and IndexCommend=1 ", 15, "MidifyTime", 1);
                        rptRelation.DataBind();

                        

                    }
                    else
                    {
                        Response.Redirect("/");
                    }

                }
            }
        }
    }
}